package com.lizhi.yun.core.handler;/**
 * @program: sfrobot-html
 * @name SerialHandler
 * @description: 串口管理
 * @author: lizhi
 * @create: 2020-04-23 17:08
 */

import com.lizhi.common.yun.entity.ListResponseResult;
import com.lizhi.utils.json.SamJsonUtil;
import com.lizhi.yun.db.stand.dao.SerialManageDao;
import com.lizhi.yun.db.stand.pojo.SerialManagePOJO;
import com.lizhi.mybatis.interceptor.PageBounds;
import com.lizhi.utils.StringUtils;
import com.lizhi.yun.deploy.NewBaseHandler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 *@program: sfrobot-html
 *@name SerialHandler
 *@description: 串口管理
 *@author: lizhi
 *@create: 2020-04-23 17:08
 */
@Slf4j
@Service
public class ServiceSerialManageHandler extends NewBaseHandler {

    @Resource
    private SerialManageDao serialManageDao;

    /**
     *功能描述 分页查询
     * @author lizhi
     * @date 2020/4/23
     * @param json:
     * @return com.lizhi.common.base.PagerView<com.lizhi.core.parameters.pojo.SerialManagePOJO>
     */
    public ListResponseResult doMain(String json) {
        Map<String, Object> map = SamJsonUtil.toMap(json);
        PageBounds pageBounds = getPageBounds(map);
        List<SerialManagePOJO> doList = serialManageDao.selectByMap(map, pageBounds);
        return getListResult(pageBounds.getCountRows(),doList, map);
    }

    /**
     *功能描述 浏览
     * @author lizhi
     * @date 2020/4/23
     * @param code:
     * @return com.lizhi.core.parameters.pojo.SerialManagePOJO
     */
    public ListResponseResult selectById(String code, String hospitalId, String hospitalSystemId) {
        SerialManagePOJO entity = serialManageDao.selectById(code, hospitalId, hospitalSystemId);
        log.info("获取到的entity:{}", entity);
        if (!StringUtils.isEmpty(entity)) {
            return getListResult(entity);
        }
        return getListResult(null);
    }
}
